package com.itany.corejava.code07_面向对象.继承;

/**
 * @author 石小俊
 * 2024年07月16日 9:49
 */
public class Test03_方法重写 {
    public static void main(String[] args) {
        Car car = new Car();
        car.show();
        Bus bus = new Bus();
        bus.show();
        MotorVehicle motorVehicle = new MotorVehicle();
        motorVehicle.show();
    }
}

class MotorVehicle {
    private String no;  // 车牌号
    private String brand;   // 品牌

    public void show() {
        System.out.println("这是一辆机动车");
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }
}

class Car extends MotorVehicle {
    private String type;    // 型号


    public void show() {
        System.out.println("这是一辆小轿车");
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}

class Bus extends MotorVehicle {
    private int seatCount;

    public void show() {
        System.out.println("这是一辆大客车");
    }

    public int getSeatCount() {
        return seatCount;
    }

    public void setSeatCount(int seatCount) {
        this.seatCount = seatCount;
    }
}
